﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Globalization;

namespace NAccounting
{
    public static class CurrentDateTimeExtensions
    {
        private static CultureInfo _culture = System.Threading.Thread.CurrentThread.CurrentUICulture;

        public static string ToStringForNullable(this DateTime? source, string formatter)
        {
            return source.HasValue ? source.Value.ToString(formatter) : "--/--/----";
        }

        public static string ToStringForNullable(this DateTime? source)
        {
            return source.ToStringForNullable(_culture.DateTimeFormat.ShortDatePattern);
        }

        public static string ToJsString(this DateTime source)
        {
            return source.ToString("MMM, dd yyyy HH:mm:ss");
        }
    }
}